import request from './axios'

//获取home页面tabs标签，频道列表
export function getUserChannels() {
  return request({
    url:"/v1_0/user/channels"
  })
}

/**
 * 获取频道的文章列表
 */
export const getArticles = params => {
  return request({
    url: '/v1_1/articles',
    params
  })
}
/**
 * 获取所有频道
 */
export const getAllChannels = () => {
  return request({
    url: 'v1_0/channels'
  })
}

//添加频道
export const addUserChannel = channels => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/channels',
    data: {
      channels
    }
  })
}
/**
 * 删除用户频道
 */
export const deleteUserChannel = channelId => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/channels/${channelId}`
  })
}


/**
 * 搜索联想建议
 */
export function getSuggestions (q) {
  return request({
    url: '/v1_0/suggestion',
    params: {
      q
    }
  })
}

/**
 * 获取搜索结果
 */
export function getSearch(params) {
  return request({
    url: "/v1_0/search",
    params
  })
}